﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FastBinarySerialization;

namespace SpeedTest
{
	[Serializable]
	public class SampleClass : SampleBase
	{
		static SampleClass()
		{
			#region Value handler
			FastBinarySerializer.Register(
				"Value",
				typeof(double),
				typeof(SampleClass),
				(instance, reader) => { ((SampleClass)instance).Value = reader.ReadDouble(); },
				(instance, writer) => { writer.Write(((SampleClass)instance).Value); });
			#endregion

			#region TimeStamp handler
			FastBinarySerializer.Register(
				"TimeStamp",
				typeof(DateTime),
				typeof(SampleClass),
				(instance, reader) => { ((SampleClass)instance).TimeStamp = new DateTime(reader.ReadInt64()); },
				(instance, writer) => { writer.Write(((SampleClass)instance).TimeStamp.Ticks); });
			#endregion
		}

		public double Value { get; set; }
		public DateTime TimeStamp { get; set; }
	}
}
